return {
	-- 安装 Mason
	{
		"williamboman/mason.nvim",
		opts = {
			ensure_installed = {
				"lua-language-server",
				"pyright",
				--"clangd",
				"stylua", -- Lua 格式化
				"codespell", -- 拼写检查
			},
		},
		config = function(_, opts)
			require("mason").setup(opts)
			local mr = require("mason-registry")
			local function ensure_installed()
				for _, tool in ipairs(opts.ensure_installed) do
					local p = mr.get_package(tool)
					if not p:is_installed() then
						p:install()
					end
				end
			end
			if mr.refresh then
				mr.refresh(ensure_installed)
			else
				ensure_installed()
			end
		end,
	},
	-- 安装 lsp，及配置
	{
		"neovim/nvim-lspconfig",
		dependencies = { "saghen/blink.cmp" },

		-- example calling setup directly for each LSP
		config = function()
			-- 获取 blink.cmp 的 LSP 能力
			local capabilities = require("blink.cmp").get_lsp_capabilities()
			local lspconfig = require("lspconfig")

			-- 添加 clangd 特定配置
			lspconfig.clangd.setup({
				capabilities = {
					textDocument = {
						completion = {
							editsNearCursor = true,
						},
					},
					offsetEncoding = { "utf-8", "utf-16" },
				},
				cmd = { "clangd" },
				filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
				root_markers = {
					".clangd",
					".clang-tidy",
					".clang-format",
					"compile_commands.json",
					"compile_flags.txt",
					"configure.ac",
				},
				single_file_support = true,
			})

			-- 诊断显示配置
			vim.diagnostic.config({
				underline = false,
				signs = true, -- 建议开启（显示行号侧边标记）
				update_in_insert = false,
				virtual_text = {
					spacing = 2,
					prefix = "●",
				},
				severity_sort = true,
				float = {
					border = "rounded",
					source = "always", -- 显示错误来源
				},
			})
		end,
	},

	-- 保存自动代码格式化
	{
		"stevearc/conform.nvim",
		event = "BufWritePre",
		opts = {
			formatters_by_ft = {
				-- 可以在 mason 里安装
				lua = { "stylua" },
				python = { "black", "isort" }, -- 新增 Python 格式化
				c = { "clang-format" }, -- 新增 C/C++ 格式化
				cpp = { "clang-format" },
				-- Use the "_" filetype to run formatters on filetypes that don't
				-- have other formatters configured.
				-- 没有安装格式的用下面默认的，删空格
				["_"] = { "trim_whitespace" },
			},

			format_on_save = function(_)
				-- Disable with a global or buffer-local variable
				if vim.g.enable_autoformat then
					return { timeout_ms = 500, lsp_format = "fallback" }
				end
			end,
		},
		init = function()
			vim.g.enable_autoformat = true
			require("snacks").toggle
				.new({
					id = "auto_format",
					name = "Auto format",
					get = function()
						return vim.g.enable_autoformat
					end,
					set = function(state)
						vim.g.enable_autoformat = state
					end,
				})
				:map("<leader>tf")
		end,
	},

	-- 代码检查
	{
		"mfussenegger/nvim-lint",
		event = { "BufWritePost", "BufReadPost" },
		linters_by_ft = {
			c = { "cpplint" },
			cpp = { "cpplint" },
			-- ... 其他配置
		},
		config = function()
			require("lint").linters_by_ft = {
				lua = { "selene" }, -- Lua 静态分析
				python = { "pylint" }, -- Python 检查
				c = { "cpplint" }, -- C/C++ 检查
				cpp = { "cpplint" },
				markdown = { "markdownlint", "codespell" }, -- 仅在 markdown 启用 codespell
				text = { "vale" }, -- 通用文本检查
			}

			vim.api.nvim_create_autocmd({ "BufWritePost", "BufReadPost" }, {
				callback = function()
					require("lint").try_lint()
				end,
			})
		end,
	},

	---===========
	-- 代码诊断信息显示
	{
		"folke/trouble.nvim",
		cmd = "Trouble",
		dependencies = { "folke/snacks.nvim" },
		keys = {
			{
				"<A-j>",
				function()
					vim.diagnostic.jump({ count = 1 })
				end,
				mode = { "n" },
				desc = "Next diagnostic",
			},
			{
				"<A-k>",
				function()
					vim.diagnostic.jump({ count = -1 })
				end,
				mode = { "n" },
				desc = "Prev diagnostic",
			},
			{ "<leader>gd", "<CMD>Trouble diagnostics toggle<CR>", desc = "Toggle diagnostics" },
			-- 其他按键绑定...
		},
		opts = { -- 直接定义 opts，避免 nil
			focus = false,
			warn_no_results = false,
			open_no_results = true,
			preview = {
				type = "float",
				border = "rounded",
				position = { 0.3, 0.3 },
				size = { width = 0.6, height = 0.5 },
			},
		},
		config = function(_, opts)
			require("trouble").setup(opts)
			-- 如果不需要状态栏集成，可删除以下部分
			local symbols = require("trouble").statusline({
				mode = "lsp_document_symbols",
				format = "{kind_icon}{symbol.name:Normal}",
			})
			if package.loaded["lualine"] then
				local lualine_opts = require("lualine").get_config()
				table.insert(lualine_opts.winbar.lualine_b, 1, {
					symbols.get,
					cond = symbols.has,
				})
				require("lualine").setup(lualine_opts)
			end
		end,
	},
	-- 消除显示 undefind global vim 警告
	{
		"folke/lazydev.nvim",
		ft = "lua", -- only load on lua files
		opts = {
			library = {
				-- See the configuration section for more details
				-- Load luvit types when the `vim.uv` word is found
				{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
			},
		},
	},
}
